home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11165 < prev    next >
Encoding:
Text File  |  1996-08-05  |  987 b   |  26 lines

  1. Path: news.unt.edu!johnw
  2. From: johnw@jove.acs.unt.edu (John R. Williams)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: given: char foo[80]; there is no such thing as element foo[80] correct? (i.e. foo[80] = '\0' is beyond the array boundary)
  5. Date: 22 Mar 1996 06:33:50 GMT
  6. Organization: University of North Texas
  7. Message-ID: <4ithke$mql@hermes.acs.unt.edu>
  8. References: <314ad16d.86316693@news> <1996Mar16.175143.10948@zcon.com>
  9. NNTP-Posting-Host: jove.acs.unt.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Syed Zaeem Hosain (szh@zcon.com) wrote:
  13. > >// Yes. This works nice and safely for any array of known size.
  14. > >foo[sizeof(foo)-1] = '\0';
  15.  
  16. This is not safe even for strings if your character type is not 
  17. 'char'. I know that sounds silly, but wchar_t *is* there for a reason, 
  18. y'know.
  19.  
  20. --
  21. class JohnWilliams: public Student, public Programmer {
  22. public:
  23.   char const *operator&() const { return "johnw@jove.acs.unt.edu"; }
  24.   char const *homepage () const { return "http://www.unt.edu/~johnw"; }
  25. };
  26.